package com.test.application.loadFile.loadTXT.demo3;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * 描述: 读取文件方法三
 * 作者: yanruizhi
 * 时间: 2024/9/24 16:58
 */
@Slf4j
@Service
public class LoadTxt3 {

    //读取文件内容
    @RequestMapping("load")
    public void load() throws Exception {
        //读取resources目录下的文件为输入流
        InputStream inputStream = LoadTxt3.class.getResourceAsStream("/file/cspsdk.ini");
        //将输入流转换为BufferedReader
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        String line;//每一行数据
        while ((line = reader.readLine()) != null) {
            log.info(line);
        }
        //关闭流
        reader.close();

    }

}
